<template>
  <div>
    <div class="box" v-for="(item, index) in list" :key="index">
      <input type="checkbox" v-model="arr" :value="item" />
      <span>{{ item }}</span>
    </div>
    <h3>选择你喜欢的幸运数字吧,他们加起来是:{{ num }}</h3>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
      arr: [],
    };
  },
  computed: {
    num() {
      return this.arr.reduce((a, b) => {
        return (a += b);
      }, 0);
    },
  },
};
</script>

<style>
.box {
  display: inline-block;
}
</style>